//
//  SelectedAreaViewModel.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/14.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "SelectedAreaViewModel.h"
#import "NSUserDefaults+Addition.h"
#import "SelectedAreaModel.h"

@implementation SelectedAreaViewModel



-(void)loadData:(DealDataResultBlock)resultBlock{
    
    NSMutableDictionary *postData = [[NSMutableDictionary alloc ] init];
    [postData setObj:[[NSUserDefaults standardUserDefaults] getUserSelectedCityID] forKey:@"CityId"];
    
    WEAKSELF
    [[BaseHttpRequest sharedInstance] sendRequestToPost:ThroughBusCity withData:postData alertMessage:@"" success:^(NSDictionary *dicData) {
        
        
        for (NSDictionary *dic in dicData[@"cityList"]) {
            SelectedAreaModel *model = [[SelectedAreaModel alloc ] initWithDictionary:dic];
            [weakSelf.resultList addObject:model];
        }
        SelectedAreaModel *m =  [weakSelf.resultList firstObject];
        weakSelf.selectedLeftKey = m.CityId;
        
        resultBlock(1,nil,nil);
    } error:^(NSString *errorMsg) {
        resultBlock(0,nil,errorMsg);
    }];
    
    
    
//    NSMutableArray *area = [[NSMutableArray alloc ] init];
//    [area addObject:@"玄武区"];
//    [area addObject:@"白下区"];
//    [area addObject:@"秦淮区"];
//    [area addObject:@"建邺区"];
//    [area addObject:@"下关区"];
//    [area addObject:@"高淳区"];
//    
//    [self.tableDataSource setObject:area forKey:@"南京市"];
//    
//    NSMutableArray *area1 = [[NSMutableArray alloc ] init];
//    [area1 addObject:@"高新区"];
//    [area1 addObject:@"吴中区"];
//    [area1 addObject:@"相城区"];
//    [area1 addObject:@"沧浪区"];
//    [area1 addObject:@"工业园区"];
//    [area1 addObject:@"平江区"];
//    [area1 addObject:@"虎丘区"];
//    [self.tableDataSource setObject:area1 forKey:@"苏州市"];
//    

}

@end
